#include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;

void accumulating(int n){
   clock_t startTime,endTime;
   startTime= clock();
   int a= 0;
//   long repitition =0;
//   do{
   	for (int i = 1;i<=n;i++){
    a+=i;
   }
//   repitition++;
//   }while(clock()-startTime<1000);
   
   endTime = clock();
   printf("\n\n'累加法'的运算结果是：%d",a);
   printf("\n\n'累加法'执行一次执行时间：%fs",(endTime - startTime)/CLOCKS_PER_SEC);
   return;
}


void gaussian(int n){
clock_t startTime,endTime;
startTime= clock();
int a = n*(n+1)/2;
endTime = clock();
printf("\n\n'高斯法'的运算结果是：%d",a);
printf("\n\n'高斯法'执行一次执行时间：%fs",(endTime - startTime)/CLOCKS_PER_SEC);
return;
}

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

long n = 0;
cout << "请输入n: ";
cin >> n;
accumulating(n);
gaussian(n);
return 0;
}